# coding=utf-8
# @Time: 2023/2/11 17:29
# @Author: zyg
# email: zhaoyiguang@lecent.cn

from selenium.webdriver.common.by import By

from base.ObjectMap import ObjectMap
from base.AccountBase import AccountBase
from common.tools import get_img_path

from logs.log import log


class AccountPage(ObjectMap, AccountBase):
    def upload_avatar(self, driver, img_name):
        """
        上传个人头像图片
        :param driver:
        :param img_name:
        :return:
        """
        log.info("上传个人头像图片:" + img_name)
        img_path = get_img_path(img_name)
        upload_xpath = self.basic_info_avatar_input()
        return self.upload(driver, By.XPATH, upload_xpath, img_path)

    def click_button(self, driver, button_name):
        """
        个人资料-点击保存按钮
        :param driver:
        :return:
        """
        log.info("个人资料-点击：" + button_name + " 按钮")
        button_xpath = self.basic_info_save_button(button_name)
        return self.element_click(driver, By.XPATH, button_xpath)
